<!DOCTYPE HTML>
<html  xmlns:th="http://www.thymeleaf.org">
<head th:include="_meta :: header">
<title>修改密码 - 管理员管理 </title>
</head>
<body>
<div class="layui-fluid">
	<div class="layui-row">
		<form class="layui-form" id="form-admin-add" action="#" th:action="@{/user/modify-password}" th:object="${user}">
			<input type="hidden" name="save" value="true"/>
			<input type="hidden" name="id" value="" th:field="*{id}"/>

			<div class="layui-form-item">
				<label for="username" class="layui-form-label">
					管理员
				</label>
				<div class="layui-input-inline">
					<input type="text" id="username" name="username"  readonly="readonly" required="" lay-verify="required"
						   autocomplete="off" class="layui-input" th:field="*{username}">
				</div>
			</div>
			<div class="layui-form-item">
				<label for="username" class="layui-form-label">
					<span class="x-red">*</span>新密码
				</label>
				<div class="layui-input-inline">
					<input type="password" id="password" placeholder="密码" name="password"  autocomplete="off" class="layui-input" >
				</div>
			</div>
			<div class="layui-form-item">
				<label for="username" class="layui-form-label">
					<span class="x-red">*</span>确认密码
				</label>
				<div class="layui-input-inline">
					<input type="password" id="password2" name="password2" placeholder="确认新密码" autocomplete="off" class="layui-input" >
				</div>
			</div>
			<div class="layui-form-item">
				<label for="username" class="layui-form-label">
					<span class="x-red">*</span>管理员密码
				</label>
				<div class="layui-input-inline">
					<input type="password" name="adminPassword"  placeholder="输入您的登录密码" autocomplete="off" class="layui-input" >
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">
				</label>
				<button  class="layui-btn" id="subbtn" type="submit">
					修改
				</button>
			</div>
		</form>
	</div>
</div>




<!--_footer 作为公共模版分离出去--> 
<div th:replace="_footer :: footerjs">
</div>
 <!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" th:src="@{/lib/jquery.validation/1.14.0/jquery.validate.js}" src="lib/jquery.validation/1.14.0/jquery.validate.js"></script> 
<script type="text/javascript" th:src="@{/lib/jquery.validation/1.14.0/validate-methods.js}" src="lib/jquery.validation/1.14.0/validate-methods.js"></script> 
<script type="text/javascript" th:src="@{/lib/jquery.validation/1.14.0/messages_zh.js}"  src="lib/jquery.validation/1.14.0/messages_zh.js"></script> 
<script type="text/javascript">
$(function(){
	$('.skin-minimal input').iCheck({
		checkboxClass: 'icheckbox-blue',
		radioClass: 'iradio-blue',
		increaseArea: '20%'
	});
	
	$("#form-admin-add").validate({
		rules:{
			password:{
				required:true,
			},
			password2:{
				required:true,
				equalTo: "#password"
			},
			adminPassword:{
				required:true,
			},
		},
		onkeyup:false,
		//focusCleanup:true,
		success:"valid",
		submitHandler:function(form){
			$(form).ajaxSubmit({
				type: 'post',
				url: "/user/modify-password" ,
				success: function(data){
					if(data == "1"){
						layer.msg('修改成功!',{icon:1,time:1000},function(){
							var index = parent.layer.getFrameIndex(window.name);
							parent.location.reload();
							parent.layer.close(index); 
						});
					}else if(data == "2"){
						layer.msg("管理员密码不正确");
					}else{
						layer.msg('修改失败!',{icon:1,time:1000});
					}
				},
                error: function(XmlHttpRequest, textStatus, errorThrown){
					layer.msg('error!',{icon:1,time:1000});
				}
			});
		
		}
	});
});
</script> 
<!--/请在上方写此页面业务相关的脚本-->
</body>
</html>